import 'package:flutter/material.dart';
import 'package:regular_assess/helper/utils/util.dart';
import 'package:regular_assess/pages/home/subs/controller.dart';

class NewsPage extends StatefulWidget {
  const NewsPage({
    Key? key,
    required this.title,
    this.isCircle = false,
  }) : super(key: key);
  final String title;
  final bool isCircle;
  @override
  State<NewsPage> createState() => _NewsPageState();
}

class _NewsPageState extends State<NewsPage>
    with AutomaticKeepAliveClientMixin {
  late String title;

  final controller = Get.find<AppletController>();
  @override
  void initState() {
    title = widget.title;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return widget.isCircle
        ? InkWell(
            onTap: () {
              controller.show();
            },
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(50.r),
                color: Colors.red,
              ),
              width: 100.r,
              height: 100.r,
            ),
          )
        : Scaffold(
            appBar: detailAppBar(
              context,
              backTap: () {
                controller.dismiss();
              },
            ),
            body: ListView(
              children: [
                Text(title),
                TextButton(
                    onPressed: () {
                      setState(() {
                        title = '值改变了';
                      });
                    },
                    child: Text('点我')),
              ],
            ),
          );
  }

  @override
  bool get wantKeepAlive => true;

  @override
  void dispose() {
    Get.log('newsPage----dispose');
    super.dispose();
  }
}
